<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Globe - ECHARTS-GL</title>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes"> <!-- Fullscreen Landscape on iOS -->
        <link rel="stylesheet" href="./common.css">
    </head>
    <body>
        <div id="main"></div>
        <script src="../node_modules/echarts/dist/echarts.js"></script>
        <script src="../dist/echarts-gl.js"></script>
        <script src="lib/jquery.min.js"></script>
        <script src="lib/dat.gui.js"></script>
        <script src="js/commonUI.js"></script>
        <script>
            var chart = echarts.init(document.getElementById('main'));

            // http://visibleearth.nasa.gov/view_cat.php?categoryID=1484
            chart.setOption({
                globe: {
                    heightTexture: 'asset/bathymetry_bw_composite_4k.jpg',

                    displacementScale: 0.1,

                    shading: 'realistic',
                    realisticMaterial: {
                        roughness: 0.8,
                        metalness: 0
                    },

                    postEffect: {
                        enable: true,
                        screenSpaceAmbientOcclusion: {
                            enable: true,
                            radius: 2,
                            intensity: 1.5,
                            quality: 'high'
                        }
                    },
                    temporalSuperSampling: {
                        enable: true
                    },
                    light: {
                        ambient: {
                            intensity: 0
                        },
                        main: {
                            intensity: 1,
                            shadow: true
                        },
                        ambientCubemap: {
                            texture: 'asset/pisa.hdr',
                            exposure: 1,
                            diffuseIntensity: 0.2
                        }
                    },
                    viewControl: {
                        autoRotate: false
                    },
                    debug: {
                        wireframe: {
                            show: true
                        }
                    }
                },
                series: []
            });

            window.addEventListener('resize', function () {
                chart.resize();
            });

            var config = {
                displacementScale: 0.1,
                displacementQuality: 'medium'
            };
            function update() {
                chart.setOption({
                    globe: config
                });
            }
            var gui = new dat.GUI();
            gui.add(config, 'displacementScale', 0, 0.5).step(0.01).onChange(update);
            gui.add(config, 'displacementQuality', ['low', 'medium', 'high', 'ultra'])
                .onChange(update);
        </script>
    </body>
</html>